<?php

namespace Admin\Controller;
class BaojiaController extends IsloginController{
    function oper(){
        $baojiaOb = M("Baojia");
        $num=$baojiaOb->count();
// 		3、规定每页显示的条数
        $pageSize=10;
// 		4、实例化分页类
        $pageOb=new \Think\Page($num,$pageSize);
// 		5、获取开始位置值
        $start=$pageOb->firstRow;
// 		6、获取分页结果
        $pageStr=$pageOb->show();
        $arr = $baojiaOb->limit("$start,$pageSize")->select();
        if($arr){
            $this->assign('pageStr',$pageStr);
            $this->assign('arr',$arr);
        }else{

        }
        $this->display();
    }
    function del(){
        $id=$_POST['id'];
        $baoOb = M("Baojia");
        $re = $baoOb->where("id=$id")->delete();
        if($re){
            echo json_encode(array('msg'=>1));
        }
        function update(){

        }
    }
    function update(){
        $id = $_GET["id"];
        $bob = M("Baojia");
        $arr = $bob->where("id=$id")->find();
        $this->assign('arr',$arr);
        $this->display();
    }
    function save(){
        $bjOb = M("Baojia");
        $re = $bjOb->data($_POST)->save();
        if($re){
            $this->success("修改成功！",U('Baojia/oper'));
        }
    }
}